/*
 * Licensed to the Tai Ping Jin Ke
 *
 * Copyright (c) 2022 .
 * All rights reserved.
 * 项目名称：太平金科-基础组件封装层-对象存储服务OSS-核心依赖
 * 版权说明：本软件属太平金融科技服务(上海)有限公司所有，在未获得太平金融科技服务(上海)有限公司正式授权情况下，任何企业和个人，不能获取、阅读、安装、传播本软件涉及的任何受知识产权保护的内容。
 */
package com.taipingframework.boot.minio;

import com.taipingframework.boot.minio.bucket.BucketConstant;
import com.taipingframework.utility.exception.UtilityException;
import io.minio.http.Method;
import io.minio.messages.Bucket;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;

import java.io.InputStream;
import java.time.Duration;
import java.util.List;

/**
 * 对象存储服务
 */
public interface ObjectStorageService {

    /**
     * 创建存储桶
     */
    void makeBucket(BucketConstant bucketConstant) throws UtilityException;

    /**
     * 移除存储桶
     */
    void removeBucket(BucketConstant bucketConstant) throws UtilityException;

    /**
     * 获取存储桶列表
     */
    List<Bucket> listBuckets() throws UtilityException;

    /**
     * 上传文件对象
     */
    void uploadFileObject(@NonNull InputStream inputStream, String objectName, BucketConstant bucketConstant) throws UtilityException;

    /**
     * Gets presigned URL of an object for HTTP method, expiry time and custom request parameters.
     */
    String getObjectUrl(String objectName, BucketConstant bucketConstant, @Nullable Method method, @Nullable Duration expiry) throws UtilityException;

    /**
     * 移除(已上传的)文件对象
     */
    void removeFileObject(String objectName, BucketConstant bucketConstant) throws UtilityException;

    /**
     * 获取(已上传的)文件对象列表
     */
    List<String> listFileObject(BucketConstant bucketConstant) throws UtilityException;

    /**
     * 下载文件对象
     */
    void downloadFileObject(String objectName, BucketConstant bucketConstant) throws UtilityException;

}
